package com.hsnn.medstgmini.settlement.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hsnn.medstgmini.Constants;
import com.hsnn.medstgmini.settlement.model.SetAcctInfo;
import com.hsnn.medstgmini.settlement.model.SetAcctTransInfo;
import com.hsnn.medstgmini.settlement.service.BankAcctInfoManager;
import com.hsnn.medstgmini.settlement.service.SettleAcctTransInfoManager;
import com.hsnn.medstgmini.sys.model.SysUser;
import com.hsnn.medstgmini.util.Pagination;

@Controller
@RequestMapping("/setAcctTransInfoHosp")
public class SetAcctTransInfoController {
	private static final Logger log = Logger
			.getLogger(AcctInfoHospController.class);

	@Autowired
	private BankAcctInfoManager bankAcctInfoManager;

	@Autowired
	private SettleAcctTransInfoManager settleAcctTransInfoManager;

	/**
	 * @category 跳转到交易明细页面
	 * @author 韩守松
	 * @date 2015年7月21日
	 * @param @param request
	 * @param @return
	 */
	@RequestMapping("/toSetAcctTransInfoHosp")
	public String toSetAcctTransInfoHosp(HttpServletRequest request,
			SetAcctInfo acctInfo) {
		SysUser user = (SysUser) request.getSession().getAttribute(
				Constants.USERINFO);
		acctInfo = bankAcctInfoManager.getAcctInfo(user);
		log.info(acctInfo);
		request.setAttribute("acctInfo", acctInfo);
		return "/settle/acctTransInfo";
	}

	/**
	 * @category 获取交易明细列表数据
	 * @author 韩守松
	 * @date 2015年7月22日
	 * @param @param request
	 * @param @param page
	 * @param @param acctTransInfo
	 * @param @return
	 */
	@RequestMapping("/getSetAcctTransInfoHospData")
	@ResponseBody
	public Pagination getSetAcctTransInfoHospData(HttpServletRequest request,
			Pagination page, SetAcctTransInfo acctTransInfo) {
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(
					Constants.USERINFO);
			page = settleAcctTransInfoManager.getBankAcctTransInfoList(page,
					acctTransInfo, user);
		} catch (Exception e) {
			log.info("获取医疗机构交易明细信息错误-->" + e);
		}
		return page;
	}

}
